<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<div class="aui-header-2 aui-gutter-column-sm">
    <div class="storage-title-container">
        <h2>{{ storageInfo.vasaAltrnateName | nil }}</h2>
        <ng-container *ngIf="ableJump">
            <div class="aui-link" (click)="openDeviceManage()" pmpermission pmOperation='OpenDeviceManagement'>
                <lv-group lvGutter='8px'>
                    <i lv-icon="aui-icon-open-link" lvColorState='true'></i>
                    <span>{{'common_device_management_label' | i18n}}</span>
                </lv-group>
            </div>
        </ng-container>
    </div>
</div>
<div class="dashed-line"></div>
<lv-form>
    <h2 class="aui-gutter-column-md">{{ 'common_basic_info_label' | i18n }}</h2>
    <lv-form-column lvWidth="50%">
        <lv-form-item *ngFor="let item of leftItems">
            <lv-form-label>
                {{ item.label}}
            </lv-form-label>
            <lv-form-control>
                <span lv-overflow>
                    {{item.value | nil}}
                </span>
            </lv-form-control>
        </lv-form-item>
    </lv-form-column>

    <lv-form-column lvWidth="50%">
        <lv-form-item *ngFor="let item of rightItems">
            <lv-form-label>
                {{ item.label}}
            </lv-form-label>
            <lv-form-control>
                <span lv-overflow>
                    {{item.value | nil}}
                </span>
            </lv-form-control>
        </lv-form-item>
    </lv-form-column>

    <ng-container *ngIf="!isHyperDetect">
        <h2 class="aui-gutter-column-md capacity-title-mg">{{ 'common_available_capacity_label' | i18n }}</h2>

        <lv-form-column lvWidth="33.333%">
            <lv-form-item>
                <lv-form-label>
                    {{'common_total_capacity_label' | i18n}}
                    <i lv-icon="aui-icon-help" lvTooltipTheme="light" lvTooltipPosition="bottom"
                       lv-tooltip="{{'system_available_capacity_desc_label' | i18n }}" lvColorState='true'
                       class="configform-constraint"></i>
                </lv-form-label>
                <lv-form-control>
                    {{ storageInfo.totalSize | capacityCalculateLabel:'1.1-3':unitconst.KB: true }}
                </lv-form-control>
            </lv-form-item>
        </lv-form-column>
        <lv-form-column lvWidth="33.333%">
            <lv-form-item>
                <lv-form-label>
                    {{'common_threshold_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    {{storageInfo.alarmThreasholdPer | nil}}
                    <ng-container *ngIf="storageInfo.alarmThreasholdPer">
                        <i lv-icon="aui-icon-edit" lvColorState='true' title="{{'common_modify_label' | i18n}}"
                           class="edit-threshold" (click)="modifyThreshold(storageInfo)"></i>
                    </ng-container>
                </lv-form-control>
            </lv-form-item>
        </lv-form-column>
        <lv-form-column lvWidth="33.333%">
            <lv-form-item>
                <lv-form-label>
                    {{'system_used_percentage_label' | i18n}}
                </lv-form-label>
                <lv-form-control>
                    {{storageInfo.sizePercent ? storageInfo.sizePercent + '%' : '--'}}
                </lv-form-control>
            </lv-form-item>
        </lv-form-column>

        <lv-form-column lvWidth="100%" class="form-column-mt">
            <div class='used-capactiy-percent-bar'>
                <lv-progress [lvValue]="storageInfo.sizePercent" [lvColors]='progressBarColor' [lvExtra]="progressExtraTpl"
                             lvShowLabel="false">
                </lv-progress>
            </div>
        </lv-form-column>

        <lv-form-column lvWidth="50%" class="form-column-mt">
            <div class="status">
                <i [ngStyle]="{ background: usedSizeColor }"></i>
                <span>
                {{ storageInfo.usedSize | capacityCalculateLabel:'1.1-3':unitconst.KB: true}}
            </span>
            </div>
            <div>
            <span class="aui-text-help-sm used-capacity-desc">
                {{'common_used_capacity_label' | i18n}}
            </span>
            </div>
        </lv-form-column>

        <lv-form-column lvWidth="50%" class="form-column-mt">
            <div class="status">
                <i [ngStyle]="{ background: '#e6ebf5' }"></i>
                <span>
                {{ storageInfo.freeSize | capacityCalculateLabel:'1.1-3':unitconst.KB: true }}
            </span>
            </div>
            <div>
            <span class="aui-text-help-sm unused-capacity-desc">
                {{'common_unused_capacity_label' | i18n}}
            </span>
            </div>
        </lv-form-column>
    </ng-container>
</lv-form>

<ng-template #progressExtraTpl>
    <div class="alarm-threashold" [ngStyle]="{'width': storageInfo.alarmThreasholdPer}"></div>
</ng-template>
